#include "../../ACUAS/ACUAS.h"
#include "../../ACUAS/ACUASLCD-CSlab.h"

PROGRAM_INIT
RANDOM_INIT
    int i=0;
    int j;
	int h;
    int rn;
    int sv;
    int pac[52];
	unsigned char numbers[52]={'A','2','3','4','5','6','7','8','9','0','J','Q','K','A','2','3','4','5','6','7','8','9','0','J','Q','K','A','2','3','4','5','6','7','8','9','0','J','Q','K','A','2','3','4','5','6','7','8','9','0','J','Q','K'};
    unsigned char symbs[52]={'c','c','c','c','c','c','c','c','c','c','c','c','c','d','d','d','d','d','d','d','d','d','d','d','d','d','h','h','h','h','h','h','h','h','h','h','h','h','h','s','s','s','s','s','s','s','s','s','s','s','s','s'};
    unsigned char newnumbers[52]={'A','2','3','4','5','6','7','8','9','0','J','Q','K','A','2','3','4','5','6','7','8','9','0','J','Q','K','A','2','3','4','5','6','7','8','9','0','J','Q','K','A','2','3','4','5','6','7','8','9','0','J','Q','K'};
    unsigned char newsymbs[52]={'c','c','c','c','c','c','c','c','c','c','c','c','c','d','d','d','d','d','d','d','d','d','d','d','d','d','h','h','h','h','h','h','h','h','h','h','h','h','h','s','s','s','s','s','s','s','s','s','s','s','s','s'};
    
	ACTIVATE_LCD  
   

  for (h=1; h<53; h++)
     pac[h-1]=h;

PROGRAM_START
  for (i=0; i<52; i++)
      {
       do
         {
           rn=RANDOM(0,51);
           sv=0; //i has to be counted
              
			   for(j=0;j<i;j++)
			      {
                   if(rn==pac[j])
                     {
                      sv=1;
                      break;
                      }
                  }
         }while (sv==1);

          pac[i]=rn;
          newnumbers[i]=numbers[rn];
          newsymbs[i]=symbs[rn];

         //LCD_XY(2,1)                //for simulation only
         //LCD_CHAR(newsymbs[i])      //for simulation only
         //LCD_XY(1,1)                //for simulation only
         //LCD_CHAR(newnumbers[i])    //for simulation only
         //WAIT_SEC(0.5)              //if you want it to go slower 
         DISPLAY_LEDS(newnumbers[i])  //to display on the leds when it's shuffling
       }

return 0;

PROGRAM_END
